package br.com.rubrol.controller;

import java.util.ArrayList;
import java.util.List;

import javax.faces.event.ActionEvent;

import br.com.rubrol.bean.Tab;

public class MainPageBean extends AbstractBaseBean {

	private static final long serialVersionUID = 1L;
	private int tabIndex = -1;
	private List<Tab> tabs;

	public MainPageBean() {
	}

	public List<Tab> getTabs() {
		return tabs;
	}

	public void setTabs(List<Tab> tabs) {
		this.tabs = tabs;
	}

	public int getTabIndex() {
		return tabIndex;
	}

	public void setTabIndex(int tabIndex) {
		this.tabIndex = tabIndex;
	}

	public int getTabSize() {
		return tabs.size();
	}

	public void removeTab(ActionEvent event) {
		if (tabs != null && tabs.size() > tabIndex) {
			tabs.remove(tabIndex);
			if (tabIndex > 0) {
				tabIndex--;
			}
		}
	}

	public void addTab(ActionEvent event) {

	}
	

	@Override
	public void initComponents() {
		// Tabs
		tabs = new ArrayList<Tab>();
		Tab tabMain = new Tab("teste", "tabmain.jspx", ++tabIndex);
		tabs.add(tabMain);

	}

}
